/**
 * URL类的用法
 */
package edu.gzz.net;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;

/**
 * @author gzz
 *
 */
public class URLRead {

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		// 
		URL url = new URL("http://www.baidu.com");
		
		InputStream is = url.openStream();
		InputStreamReader ir = new InputStreamReader(is);
		BufferedReader br = new BufferedReader(ir);

		String str = br.readLine();

		while (str != null) {
			System.out.println(str);
			str = br.readLine();
		}

		br.close();
		ir.close();
		is.close();
	}

}
